#! /bin/bash

#title           :ymy_qrencode.sh
#description     :This script will create a yad dialog generating qrcodes
#author		     :frimo
#date            :2020-05-28
#version         :0.1
#usage		     :ymy_qrencode.sh
#    _    
# (///)(/ 
# /    /  

# create yad gui
dialog=$(yad --width=640 --title="yad my qrencode" \
--center \
--text="Configure your QR-Code:" \
--image="../icon/ymy_64.png" \
--form \
--field="filename:SFL" \
--field="qrcode")

# get status of yad dialog
status=$?

# quit application if status is 0
[[ $status -eq 1 ]] && exit 0

# get values from yad dialog
filename=$(echo $dialog | awk 'BEGIN {FS="|" } { print $1 }')
qrcode=$(echo $dialog | awk 'BEGIN {FS="|" } { print $2 }')
#usersigningkey=$(echo $dialog | awk 'BEGIN {FS="|" } { print $4 }')

# print created bash command
echo "qrencode -o $filename $qrcode"

# execute created bash command
qrencode -o $filename $qrcode

# exit application
exit 0
